#region Microsoft Public License
/*
 * (c) Copyright Chenjun Wu. http://utablesdk.codeplex.com
 * 
 * This source is subject to the Microsoft Public License (Ms-PL).
 * Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
 * All other rights reserved.
 */
#endregion

﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Collections.ObjectModel;
using System.Globalization;

namespace UTable.Objects.Controls
{
    /// <summary>
    /// Interaction logic for DirectoryItemView.xaml
    /// </summary>
    public partial class DirectoryItemView : FileItemViewBase
    {
        public DirectoryItemView()
        {
            InitializeComponent();
        }

        private void EnterButton_Click(object sender, RoutedEventArgs e)
        {
            String path = (this.DataContext as FileItemData).FilePath;
            FileExplorer.DirectoryPath = path;
        }
    }

    [ValueConversion(typeof(String), typeof(ImageSource))]
    public class DirectoryIconSelector : IValueConverter
    {
        public object Convert(object value, Type typeTarget, object param, CultureInfo culture)
        {
            object result = value;
            if (value != null)
            {
                String folder = "..\\..\\Images\\FileIcons\\";
                String path = value as String;
                if (FileNameSelector.IsDiskName(path))
                    result = folder + "disk.png";
                else
                    result = folder + "directory.png";
            }
            return result;
        }
        public object ConvertBack(object value, Type typeTarget, object param, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
